#include "CTaskCenter.h"

CTaskCenter::CTaskCenter() {
}

CTaskCenter::~CTaskCenter() {
}

void CTaskCenter::Push(const CTaskData& task) {
	std::unique_lock <std::mutex> lock(mt);
	taskList.push(task);
}

bool CTaskCenter::Get(CTaskData& task) {
	std::unique_lock <std::mutex> lock(mt);
	if (taskList.empty())
		return false;

	task = taskList.front();
	taskList.pop();

	return true;
}

void CTaskCenter::Clear(void) {
	
	std::unique_lock <std::mutex> lock(mt);

	while(!taskList.empty()) {
		taskList.pop();
	}
}

int CTaskCenter::GetSize(void) {
	std::unique_lock <std::mutex> lock(mt);
	return taskList.size();
}
